# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from typing import Union
from fastapi import Query
from pydantic import BaseModel, Field


class AiPoolKeysChannelIn(BaseModel):
    """ AI密钥渠道参数 """
    scene: str = Query(..., description="密钥场景: [对话=chat,向量=vector]")


class AiPoolKeysSearchIn(BaseModel):
    """ AI密钥搜索参数 """
    page_no: int = Query(default=1, gt=0, description="当前页码")
    page_size: int = Query(default=15, gt=0, le=200, description="每页条数")
    channel: str = Query(default="", description="密钥渠道")
    scene: str = Query(..., description="密钥场景: [对话=chat,向量=vector]")
    status: Union[int, str, None] = Query(default=None, description="密钥状态: [0=正常,1=禁用]")
    keyword: Union[str, None] = Query(default=None, description="关键词")


class AiPoolKeysDetailIn(BaseModel):
    """ AI密钥详情参数 """
    id: int = Query(..., gt=0, description="密钥ID")


class AiPoolKeysAddIn(BaseModel):
    """ AI密钥新增参数 """
    scene: str = Field(..., min_length=1, description="密钥场景: [chat=对话,vector=向量]")
    channel: str = Field(..., min_length=1, max_length=100, description="密钥通道")
    mark: str = Field(default="", description="模型标识")
    app_id: str = Field(default="", description="APPID")
    api_key: str = Field(default="", description="APIKey")
    api_secret: str = Field(default="", description="APISecret")
    sort: int = Field(default=0, ge=0, description="排序编号")
    is_disable: int = Field(default=0, ge=0, le=1, description="是否禁用: [0=否, 1=是]")

    @classmethod
    def messages(cls):
        return {

        }


class AiPoolKeysEditIn(BaseModel):
    """ AI密钥新增参数 """
    id: int = Field(..., ge=0, description="密钥ID")
    scene: str = Field(..., min_length=1, description="密钥场景: [chat=对话,vector=向量]")
    channel: str = Field(..., min_length=1, max_length=100, description="密钥通道")
    mark: str = Field(default="", description="模型标识")
    app_id: str = Field(default="", description="APPID")
    api_key: str = Field(default="", description="APIKey")
    api_secret: str = Field(default="", description="APISecret")
    sort: int = Field(ge=0, default=0, description="排序编号")
    is_disable: int = Field(description="是否禁用: [0=否, 1=是]")

    @classmethod
    def messages(cls):
        return {

        }


class AiPoolKeysIdIn(BaseModel):
    """ AI密钥Id参数 """
    id: int = Field(gt=0, description="密钥ID", examples=[1])

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1
            }
        }


"""--------------- Separator ---------------"""


class AiPoolKeysChannelVo(BaseModel):
    """ AI密钥渠道Vo """
    name: str = Field(description="渠道名称")
    mark: str = Field(description="渠道标识")
    channel: str = Field(description="渠道通道")
    logo: str = Field(description="渠道图标"),
    is_disable: bool = Field(default=False, description="是否禁用")

    class Config:
        json_schema_extra = {
            "example": {
                "name": "智普清言",
                "mark": "zhipu",
                "channel": "zhipu",
                "logo": "https://xx.cn/static/models/llm_zhipu.png",
                "is_disable": False
            }
        }


class AiPoolKeysListVo(BaseModel):
    """ AI密钥列表Vo """
    id: int = Field(description="ID")
    scene: str = Field(description="密钥场景")
    app_id: str = Field(description="APPID")
    api_key: str = Field(description="APIKey")
    api_secret: str = Field(description="APISecret")
    error: str = Field(description="错误信息")
    sort: int = Field(description="排序编号")
    is_disable: int = Field(description="是否禁用: [0=否, 1=是]")
    create_time: str = Field(description="创建时间")
    update_time: str = Field(description="更新时间")

    class Config:
        json_schema_extra = {
            "example": {

            }
        }


class AiPoolKeysDetailVo(BaseModel):
    """ AI模型渠道Vo """
    id: int = Field(description="ID")
    scene: str = Field(description="密钥场景")
    app_id: str = Field(description="APPID")
    api_key: str = Field(description="APIKey")
    api_secret: str = Field(description="APISecret")
    sort: int = Field(description="排序编号")
    is_disable: int = Field(description="是否禁用: [0=否, 1=是]")

    class Config:
        json_schema_extra = {
            "example": {

            }
        }
